*********************************************************************************
* "Women's leadership and the gendered consequences of austerity"
* (Replication file)
*
* Country-year dataset
*********************************************************************************

* Data loading
**************
  
  use "IMFWPS_replication", clear
  
  xtset cid year 
  cmp setup 
  set matsize 800
  qui xi:reg IMFnn i.year i.cid

  g femmin=maleshare_min<1 & maleshare_min!=.
  lab var femmin "Women minister(s)"
  g femlead=maleshare_lead<1 & maleshare_lead!=. 
  lab var femlead "Female leader"
  g femfm=(maleshare_fm==0) if maleshare_fm!=.
  lab var femfm "Female finance minister"
  
  g CNF=pop_f*lfpr_f/100*cpse_tef/(1e6)
  lab var CNF "Number of women employed"
  
  egen FEMMIN=mean(femmin), by(year)
  qui g fiv=WIP*FEMMIN 
  lab var fiv "Instrument for female minister"
  
  
* Main results
**************

* Female employment 
  qui reghdfe cpse_tef l.IMFnn##l.femmin cpse_tem, a(cid year) cl(cid)
  est store a11
  qui reghdfe cpse_tef l.IMFnn##l.femmin $LX cpse_tem, a(cid year) cl(cid)
  est store a12
 
* Gender wage ratio 
  qui reghdfe cpsggap l.IMFnn##femmin cprgg, a(cid year) cl(cid)
  est store a21
  qui reghdfe cpsggap l.IMFnn##femmin $LX cprgg, a(cid year) cl(cid)
  est store a22

  ** Table 1 **
  estout a1* a2*, drop(_* *oL* *0b* *0.*) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2_a, fmt(0 0 3))

  est restore a12
  margins l.IMFnn#l.femmin
  est restore a22
  margins l.IMFnn#femmin
  

* Appendix
**********

* Descriptives (Table A1)

  est restore a11
  qui estpost su cpse_tef cprgg IMFnn BA2LAB pub BA2FP femmin femlead femfm lngdppc lncpi growth_WDI crisis_LV p_ipolity cpse_tem cprgg y_f_pp  pse_tef pse_tem psgg prgg CNF WIP FEMMIN nUnder if e(sample)
  esttab ., cells("count mean sd min max")

  
* Panel with gaps 

  qui reghdfe pse_tef IMFnn##femmin pse_tem, a(cid year) cl(cid)
  est store r11
  qui reghdfe pse_tef IMFnn##femmin $LX pse_tem, a(cid year) cl(cid)
  est store r12
  qui reghdfe cpsggap l.IMFnn##femmin prgg, a(cid year) cl(cid)
  est store r21
  qui reghdfe cpsggap l.IMFnn##femmin $LX prgg, a(cid year) cl(cid)
  est store r22

  ** Table A2 **
  estout r1* r2*, drop(_* *0.* *0b* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2_a, fmt(0 0 3))
  
 
* Types of IMF conditionality   
  
  g X1=l.BA2LAB
  g X2=l.femmin
  qui reghdfe cpse_tef c.X1##X2 $LX cpse_tem if l.IMFnn==1, a(cid year) cl(cid)
  est store c11
  replace X1=l.pub
  qui reghdfe cpse_tef c.X1##X2 cpse_tem if l.IMFnn==1, a(cid year) cl(cid)
  est store c12
  replace X1=l.BA2FP
  qui reghdfe cpse_tef c.X1##X2 $LX cpse_tem if l.IMFnn==1, a(cid year) cl(cid)
  est store c13
  
  replace X1=l.BA2LAB
  replace X2=femmin
  qui reghdfe cpsggap c.X1##X2 $LX cprgg if l.IMFnn==1, a(cid year) cl(cid)
  est store c21
  replace X1=l.pub
  qui reghdfe cpsggap c.X1##X2 cprgg if l.IMFnn==1, a(cid year) cl(cid)
  est store c22
  replace X1=l.BA2FP
  qui reghdfe cpsggap c.X1##X2 $LX cprgg if l.IMFnn==1, a(cid year) cl(cid)
  est store c23
  
  ** Table A3 **
  estout c1* c2*, keep(X1* 1.X2*) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2_a, fmt(0 0 3))
  drop X1 X2
  
  
* Selection effect: Matching on observables

  foreach x in lngdppc lncpi growth crisis {
	g L_`x'=l.`x'
	}
	
  ebalance IMFnn L_* 
  
  qui reghdfe cpse_tef l.IMFnn##l.femmin cpse_tem [aw=_webal], a(cid year) cl(cid)
  est store m11
  qui reghdfe cpse_tef l.IMFnn##l.femmin $LX cpse_tem [aw=_webal], a(cid year) cl(cid)
  est store m12
  qui reghdfe cpsggap l.IMFnn##femmin cprgg [aw=_webal], a(cid year) cl(cid)
  est store m21
  qui reghdfe cpsggap l.IMFnn##femmin $LX cprgg [aw=_webal], a(cid year) cl(cid)
  est store m22

  ** Table A4 **
  estout m1* m2*, drop(_* *oL* *0b* *0.*) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2_a, fmt(0 0 3))  

  
* Selection effect: Instrumental approach

  g IMFxFEMMIN=l.IMFnn*l.femmin

  ** Public employment **
  mat F=J(5,4,0)
  qui cmp (cpse_tef=l.IMFnn IMFxFEMMIN l.femmin cpse_tem _Icid* _Iyear*) (l.IMFnn=l.iv0 _Icid* _Iyear*), indicators(1 1) cl(cid)
  est store i11
   mat F[4,1]=e(N1)
   mat F[1,1]=e(N2)
   qui test [lIMFnn]l.iv0
   mat F[3,1]=r(chi2)
   qui reghdfe cpse_tef l.IMFnn IMFxFEMMIN l.femmin cpse_tem, a(cid year)
   mat F[5,1]=e(r2_a)
   qui reghdfe l.IMFnn l.iv0, a(cid year)
   mat F[2,1]=e(r2_a)
   
  qui cmp (cpse_tef=l.IMFnn IMFxFEMMIN l.femmin $LX cpse_tem _Icid* _Iyear*) (l.IMFnn=l.iv0 $LX _Icid* _Iyear*), indicators(1 1) cl(cid)
  est store i12
   mat F[4,2]=e(N1)
   mat F[1,2]=e(N2)
   qui test [lIMFnn]l.iv0
   mat F[3,2]=r(chi2)
   qui reghdfe cpse_tef l.IMFnn IMFxFEMMIN l.femmin $LX cpse_tem, a(cid year)
   mat F[5,2]=e(r2_a)
   qui reghdfe l.IMFnn l.iv0 $LX, a(cid year)
   mat F[2,2]=e(r2_a)
 
  ** Gender wage ratio **
  replace IMFxFEMMIN=l.IMFnn*femmin
  qui cmp (cpsggap=l.IMFnn IMFxFEMMIN femmin cprgg _Icid* _Iyear*) (l.IMFnn=l.iv0 _Icid* _Iyear*), indicators(1 1) cl(cid)
  est store i21
   mat F[4,3]=e(N1)
   mat F[1,3]=e(N2)
   qui test [lIMFnn]l.iv0
   mat F[3,3]=r(chi2)
   qui reghdfe cpsgg l.IMFnn IMFxFEMMIN l.femmin cprgg, a(cid year)
   mat F[5,3]=e(r2_a)
   qui reghdfe l.IMFnn l.iv0, a(cid year)
   mat F[2,3]=e(r2_a)
   
  qui cmp (cpsggap=l.IMFnn IMFxFEMMIN femmin $LX cprgg _Icid* _Iyear*) (l.IMFnn=l.iv0 $LX _Icid* _Iyear*), indicators(1 1) cl(cid)
  est store i22
   mat F[4,4]=e(N1)
   mat F[1,4]=e(N2)
   qui test [lIMFnn]l.iv0
   mat F[3,4]=r(chi2)
   qui reghdfe cpsgg l.IMFnn IMFxFEMMIN l.femmin $LX cprgg, a(cid year)
   mat F[5,4]=e(r2_a)
   qui reghdfe l.IMFnn l.iv0 $LX, a(cid year)
   mat F[2,4]=e(r2_a)

  ** Table A5 **
  estout i1* i2*, drop(_* _I*) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2_a, fmt(0 0 3))
  mat li F
  
  
* Instruments for female ministers  
  
  replace IMFxFEMMIN=l.IMFnn*l.femmin
  
  qui cmp (cpse_tef=l.IMFnn IMFxFEMMIN l.femmin cpse_tem _Icid* _Iyear*) (l.femmin=l.fiv l.WIP cpse_tem _Icid* _Iyear*), indicators(1 1) ro cl(cid) tech(dfp nr) difficult iterate(50)
   est store f11
   mat F[1,1]=e(N2)
   mat F[4,1]=e(N1)
   qui test [lfemmin]l.fiv
   mat F[3,1]=r(chi2)
   qui reghdfe cpse_tef l.IMFnn IMFxFEMMIN l.femmin cpse_tem, a(cid year)
   mat F[5,1]=e(r2_a)
   qui reghdfe l.femmin l.fiv l.WIP cpse_tem, a(cid year)
   mat F[2,1]=e(r2_a)
   
  qui cmp (cpse_tef=l.IMFnn IMFxFEMMIN l.femmin $LX cpse_tem _Icid* _Iyear*) (l.femmin=l.fiv l.WIP $LX cpse_tem _Icid* _Iyear*), indicators(1 1) ro cl(cid) tech(dfp nr) difficult iterate(50) 
   est store f12
   mat F[1,2]=e(N2)
   mat F[4,2]=e(N1)
   qui test [lfemmin]l.fiv
   mat F[3,2]=r(chi2)
   qui reghdfe cpse_tef l.IMFnn IMFxFEMMIN l.femmin $LX cpse_tem, a(cid year)
   mat F[5,2]=e(r2_a)
   qui reghdfe l.femmin l.fiv l.WIP $LX cpse_tem, a(cid year)
   mat F[2,2]=e(r2_a)
   
  qui cmp (cpsggap=l.IMFnn IMFxFEMMIN l.femmin cprgg _Icid* _Iyear*) (l.femmin=l.fiv l.WIP cprgg _Icid* _Iyear*), indicators(1 1) ro cl(cid) tech(dfp nr) difficult iterate(50)
   est store f21
   mat F[1,3]=e(N2)
   mat F[4,3]=e(N1)
   qui test [lfemmin]l.fiv
   mat F[3,3]=r(chi2)
   qui reghdfe cpsggap l.IMFnn IMFxFEMMIN l.femmin cprg, a(cid year)
   mat F[5,3]=e(r2_a)
   qui reghdfe l.femmin l.fiv l.WIP cprg, a(cid year)
   mat F[2,3]=e(r2_a)
   
  qui cmp (cpsggap=l.IMFnn IMFxFEMMIN l.femmin $LX cprgg _Icid* _Iyear*) (l.femmin=l.fiv l.WIP $LX cprgg _Icid* _Iyear*), indicators(1 1) ro cl(cid) tech(dfp nr) difficult iterate(50)
   est store f22
   mat F[1,4]=e(N2)
   mat F[4,4]=e(N1)
   qui test [lfemmin]l.fiv
   mat F[3,4]=r(chi2)
   qui reghdfe cpsgg l.IMFnn IMFxFEMMIN l.femmin $LX cprgg, a(cid year)
   mat F[5,4]=e(r2_a)
   qui reghdfe l.femmin l.fiv l.WIP $LX cprgg, a(cid year)
   mat F[2,4]=e(r2_a)
    
  ** Table A6 **
  estout f1* f2*, drop(_* _I*) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2_a, fmt(0 0 3))
  mat li F
  

* Different measures: total women employment

  ** Option 1: Control for female work participation in private sector 
  qui reghdfe cpse_tef l.IMFnn##l.femmin cpse_tem cy_f_pp, a(cid year) cl(cid)
  est store n11
  qui reghdfe cpse_tef l.IMFnn##l.femmin $LX cpse_tem cy_f_pp, a(cid year) cl(cid)
  est store n12
  
  ** Option 2: Change in total female public-sector employment 
  qui reghdfe d.CNF l.CNF l.IMFnn##femmin cpse_tem, a(cid year) cl(cid)
  est store n21
  qui reghdfe d.CNF l.CNF l.IMFnn##femmin $LX cpse_tem, a(cid year) cl(cid)
  est store n22
 
  ** Table A7 **
  estout n1* n2*, drop(_* *0.* *0b*) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2_a, fmt(0 0 3))
  
  
* Female finance minister and female leader
    
  qui reghdfe cpse_tef l.IMFnn##l.femmin l.IMFnn##l.femlead $LX cpse_tem, a(cid year) cl(cid)
  est store g11
  qui reghdfe cpse_tef l.IMFnn##l.femmin l.IMFnn##l.femfm $LX cpse_tem, a(cid year) cl(cid)
  est store g12
  qui reghdfe cpsggap l.IMFnn##l.femmin l.IMFnn##l.femlead $LX cprgg, a(cid year) cl(cid)
  est store g21
  qui reghdfe cpsggap l.IMFnn##l.femmin l.IMFnn##l.femfm $LX cprgg, a(cid year) cl(cid)
  est store g22

  ** Table A8 **
  estout g1* g2*, drop(_* *oL* *0b* ) starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) stats(N N_clust r2_a, fmt(0 0 3))

  
* Figures
*********  

  g IMFwfem=IMFnn==1 & femmin==1
  g IMFwofem=IMFnn==1 & femmin==0
  dynardl cpse_tef IMFwfem IMFwofem cpse_tem, time(11) trend levels(.,1,1,1) lags(1,.,.,.) diffs(.,.,.,.) shockvar(IMFwofem) shockval(1) sims(500) graph saving("dynardl_IMFwofem.dta")
  dynardl cpse_tef IMFwfem IMFwofem cpse_tem, time(11) trend levels(.,1,1,1) lags(1,.,.,.) diffs(.,.,.,.) shockvar(IMFwfem) shockval(1) sims(500) graph saving("dynardl_IMFwfem.dta")
    ** combine both datasets into one **
	*** rename mean_01 meanw
	*** rename ul_76 ul_75w
	*** rename ll_76 ll_75w
  preserve
   use dynardl_results_PSEMP, clear
   g T=time-10
   twoway (line mean T, lwidth(0.8) lcolor(blue)) (line meanw T, lwidth(0.9)) (line ll_75 ul_75 T, lcolor(blue blue blue) lpattern(solid dash dash)) (line ll_75w ul_75w T), scheme(s1mono) xline(0, lpattern(dash)) xtitle(Relative time to IMF program) ytitle(Female employment share) legend(off) 
   twoway (line mean T, lwidth(0.8) lcolor(blue)) (line meanw T, lwidth(0.9)) , scheme(s1mono) xline(0, lpattern(dash)) xtitle(Relative time to IMF program) ytitle(Female employment share) legend(off) 
  restore

  dynardl cpsggap IMFwfem IMFwofem cprggap, time(11) trend levels(.,1,1,1) lags(1,.,.,.) diffs(.,.,.,.) shockvar(IMFwofem) shockval(1) sims(500) graph saving("dynardl_IMFwofem.dta")
  dynardl cpsggap IMFwfem IMFwofem cprggap, time(11) trend levels(.,1,1,1) lags(1,.,.,.) diffs(.,.,.,.) shockvar(IMFwfem) shockval(1) sims(500) graph saving("dynardl_IMFwfem.dta")  
    ** combine both datasets into one 
  	*** rename mean_01 meanw
	*** rename ul_76 ul_75w
	*** rename ll_76 ll_75w
  preserve
   use dynardl_results_GWR, clear
   g T=time-10
   twoway (line mean T, lwidth(0.8) lcolor(blue)) (line meanw T, lwidth(0.9)) (line ll_75 ul_75 T, lcolor(blue blue blue) lpattern(solid dash dash)) (line ll_75w ul_75w T), scheme(s1mono) xline(0, lpattern(dash)) xtitle(Relative time to IMF program) ytitle(Gender wage ratio) legend(off) 
   twoway (line mean T, lwidth(0.8) lcolor(blue)) (line meanw T, lwidth(0.9)), scheme(s1mono) xline(0, lpattern(dash)) xtitle(Relative time to IMF program) ytitle(Gender wage ratio) legend(off)  
  restore

